package com.ptmall.app.view;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;

import com.ptmall.app.R;


/**
 * Created by MacBook on 17/3/30.
 */

public class OilPassDialog {
    private Onclick onclick;
    public void setonclick(Onclick onclick){
        this.onclick =onclick;
    }
    private Dialog mDialog;
    private Button qd;
    private ImageView gb;
    private EditText pass;
    public OilPassDialog(Context context) {
        View view = LayoutInflater.from(context).inflate(R.layout.oil_pass,null);
        qd = (Button) view.findViewById(R.id.qd);
        gb = (ImageView) view.findViewById(R.id.gb);
        pass = (EditText) view.findViewById(R.id.pass);
        mDialog = new Dialog(context, R.style.dialogDim);
        mDialog.setContentView(view);
        mDialog.setCanceledOnTouchOutside(true);
        final Window win = mDialog.getWindow();
        win.setWindowAnimations(R.style.dialogAnim);

        qd.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                onclick.Yes(pass.getText().toString());
                mDialog.dismiss();
            }
        });
        gb.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mDialog.dismiss();
            }
        });
    }


    public void show() {
        mDialog.show();
    }

    public void dismiss() {
        mDialog.dismiss();
    }


    public interface Onclick{
        void Yes(String pass);
    }

    public boolean isshow(){
        if(mDialog.isShowing()){
            return true;
        }else {

            return false;
        }
    }

    public void setCanceledOnTouchOutside(boolean cacel) {
        if (null != mDialog) {
            mDialog.setCanceledOnTouchOutside(cacel);
        }
    }
}
